 #@layout()

#define script()
<script>

    function doDel(id) {
        if (confirm('确定要删除该表单吗？删除后该表单的数据也一并删除并不可恢复')) {
            ajaxGet("/admin/form/doDel/" + id);
        }
    }

    function published(id) {
        ajaxGet("/admin/form/doPublish/" + id);
    }

    function unPublished(id) {
        ajaxGet("/admin/form/doUnPublish/" + id);
    }

    $(function () {
        $(".js-morelist").click(function (e) {
            e.preventDefault();
            $(this).parents(".form-operate-bar").next(".form-menu-list").toggle();
        })
    })

</script>
#end
#define css()
<style>

</style>
#end

#define content()

<section class="content-header">
    <div class="container-fluid">
        <div class="row">
            <div class="col-sm-6">
                <div class="row mb-2">
                    <div class="col-sm-12">
                        <h1>
                            表单管理
                            <small data-toggle="tooltip" title="" data-placement="right"
                                   data-trigger="hover"><i class="nav-icon far fa-question-circle"></i></small>
                            <small> 首页 / 表单 / 表单管理</small>
                        </h1>

                    </div>
                </div>
            </div>

            <div class="col-sm-6 ">
                <div class=" float-sm-right" style="padding-top: 15px">
                    <a href="edit" type="button" class="btn btn-primary"><i class="fas fa-plus"></i>新建</a>
                </div>
            </div>

        </div>
    </div>
</section>

<section class="content">

    <div class="row">
        <div class="col-12">
            <div class="card card-outline card-primary">
                <div class="card-header with-border">

                    <form class=" admin-search-panel ajaxSubmit" action="#(CPATH)/admin/form/list" method="get">
                        <div class="row">

                            <div class="form-group col-lg-2">
                                <input type="text" class="form-control" placeholder="请输入名称" name="name"
                                       value="#para('name')">
                            </div>

                            <div class="form-group col-lg-2">
                                <button type="submit" class="btn btn-primary ">查询</button>
                                <button type="reset" class="btn btn-default">重置</button>
                            </div>
                        </div>
                    </form>

                </div>
                <div class="card-body row">

                    #for(entry : page.list)
                    <div class="col-md-3">
                        <div class="jpress-form-item">
                                <div class="jpress-form-item-header">
                                    <i class="bi bi-bar-chart-fill"></i>
                                     #(entry.name ??)
                                </div>

                                #if(entry.isPublished())
                                <div class="form-state-published">已经发布</div>
                                #else
                                <div class="form-state-unpublish">未发布</div>
                                #end
                                <div class="jpress-form-item-footer">
                                    <span>#(entry.data_count ??)份数据</span>
                                    <span class="float-right">#if(entry.timeDifference ??) #(entry.timeDifference ??)前 #end</span>
                                </div>
                            <div class="form-operate-bar">
                                <div class="d-flex justify-content-between">
                                    #if(entry.isPublished())
                                    <a href="#(CPATH)/admin/form/data/#(entry.id ??)"><i class="bi bi-file-earmark-text-fill pr-1"></i>查看数据</a>
                                    <a href="#(CPATH)/admin/form/edit/#(entry.id ??)"><i class="bi bi-pencil-fill pr-1"></i>编辑</a>
                                    <a href="javascript:;" onclick="unPublished('#(entry.id)')"><i class="bi bi-lightning-fill pr-1" aria-hidden="true"></i>下线</a>
                                    #else
                                    <a href="#(CPATH)/admin/form/design/#(entry.id ??)"><i class="bi bi-back pr-1"></i>表单设计</a>
                                    <a href="#(CPATH)/admin/form/edit/#(entry.id ??)"><i class="bi bi-pencil-fill pr-1"></i>编辑</a>
                                    <a href="javascript:;" onclick="published('#(entry.id)')"><i class="fa fa-paper-plane pr-1" aria-hidden="true"></i> 发布</a>
                                    #end
                                    <div class="d-inline-block dropdown show">
                                        <a href="javascript:void(0);" class="video-operation" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="bi bi-three-dots"></i></a>
                                        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink">
                                            <a class="dropdown-item" href="#(entry.url ??)" target="_blank"> 查看预览</a>
                                            <a class="dropdown-item" href="javascript:void(0);" onclick="doDel('#(entry.id ??)')">删除</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    #end

                </div>
                <div class="card-footer">
                    <div class="row">
                        <div class="col-sm-6">
                        </div>

                        <div class="col-sm-6">
                            #@_paginate()
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

</section>
#end
